var editor_js=true;function BXHTMLEditor(t,e){GLOBAL_pMainObj[t]=this;name_cur_obj=t;this.start_func=e?e:function(){};this.pMainObj=this;this.arBarHandlersCache=[];this.name=t;this.showTooltips4Components=true;this.visualEffects=true;this.arUndoBuffer=[];this.SessionLostStr="BX_EDITOR_ERROR_SESSION_EXPIRED";this.iUndoPos=-1;this.sOnChangeLastType="";this.customToolbars=true;this.bDotNet=window.bDotNet||false;this.limit_php_access=limit_php_access;this.lastCursorId="bx-editor-cursor-id";this.bxTags={};this.bLoadFinish=false;this.isSubmited=false;if(window.lca){_$lca_only=false;_$arComponents=window._$arComponents||false;_$lca_to_output=_$arComponents?true:false}this.fullEdit=this.name=="CONTENT";this.sOnChangeLastSubType="";this.sLastContent="";this.bSkipChanges=false;this.sFirstContent=null;if(BXEditorLoaded)this.OnBeforeLoad();else BXEditorRegister(this)}BXHTMLEditor.prototype.CreateElement=BXCreateElement;BXHTMLEditor.prototype.OnBeforeLoad=function(){this.allowedTaskbars=window["ar_"+this.name+"_taskbars"];this.BXPreloader=new BXPreloader([{func:BX.proxy(this.GetConfig,this),params:[]},{obj:this,func:this.PreloadTaskbarsData}],{obj:this,func:this.OnLoad});this.BXPreloader.LoadStep()};BXHTMLEditor.prototype.PreloadTaskbarsData=function(t){var e=SETTINGS[this.name].arTaskbarSettings;try{if(this.bDotNet){var i=!e||!e["ASPXComponentsTaskbar"]||e["ASPXComponentsTaskbar"].show;if(this.allowedTaskbars["ASPXComponentsTaskbar"]&&i)this.BXPreloader.AddStep({obj:this,func:this.LoadASPXComponents})}else{var o=false;if(e)o=e["BXComponents2Taskbar"];if(this.allowedTaskbars["BXComponents2Taskbar"]&&(!o||o.show))this.BXPreloader.AddStep({obj:this,func:this.LoadComponents2})}}catch(t){_alert(this.name+": ERROR:  pMainObj.PreloadTaskbarsData")}t.func.apply(t.obj)};BXHTMLEditor.prototype.OnLoad=function(){var t=this;this.bShowed=true;this.bDragging=false;this.bNotSaved=false;this.bFirstClick=false;this.className="BXHTMLEditor";this.arEventHandlers=[];this.pDocument=document;this.bTableBorder=false;this.pWnd=BX(this.name+"_object");this.pValue=BX("bxed_"+this.name);this.arToolbarSet=[];this.toolArea=[];this.arTaskbarSet=[];this.pParser=new BXParser(this);this.bEditSource=false;this.arConfig=window["ar_"+this.name+"_config"];this.bRenderComponents=this.arConfig.renderComponents;this.bRenderStyleList=styleList_render_style;if(!this.pWnd||!BX.isNodeInDom(this.pWnd)){BX.closeWait();return}this.bodyParams="";if(this.arConfig.body_class)this.bodyParams+=' class="'+this.arConfig.body_class+'"';if(this.arConfig.body_id)this.bodyParams+=' id="'+this.arConfig.body_id+'"';if(BX.WindowManager){BX.WindowManager.setStartZIndex(2010);BX.WindowManager.disableKeyCheck()}this.oTransOverlay=new BXTransOverlay({edId:this.name});this.fullEditMode=window.fullEditMode||false;this.pParser.ClearHBF();window.CACHE_DISPATCHER=[];if(this.arConfig.sBackUrl)this.arConfig.sBackUrl=this.arConfig.sBackUrl.replace(/&amp;/gi,"&");if(this.OnLoad_ex)this.OnLoad_ex();if(this.arConfig["ar_entities"].toString()=="")this.arConfig["ar_entities"]=[];else this.arConfig["ar_entities"]=this.arConfig["ar_entities"].toString().split(",");var e={},i;e["umlya"]=["&iquest;","&Agrave;","&Aacute;","&Acirc;","&Atilde;","&Auml;","&Aring;","&AElig;","&Ccedil;","&Egrave;","&Eacute;","&Ecirc;","&Euml;","&Igrave;","&Iacute;","&Icirc;","&Iuml;","&ETH;","&Ntilde;","&Ograve;","&Oacute;","&Ocirc;","&Otilde;","&Ouml;","&times;","&Oslash;","&Ugrave;","&Uacute;","&Ucirc;","&Uuml;","&Yacute;","&THORN;","&szlig;","&agrave;","&aacute;","&acirc;","&atilde;","&auml;","&aring;","&aelig;","&ccedil;","&egrave;","&eacute;","&ecirc;","&euml;","&igrave;","&iacute;","&icirc;","&iuml;","&eth;","&ntilde;","&ograve;","&oacute;","&ocirc;","&otilde;","&ouml;","&divide;","&oslash;","&ugrave;","&uacute;","&ucirc;","&uuml;","&yacute;","&thorn;","&yuml;","&OElig;","&oelig;","&Scaron;","&scaron;","&Yuml;"];e["greek"]=["&Alpha;","&Beta;","&Gamma;","&Delta;","&Epsilon;","&Zeta;","&Eta;","&Theta;","&Iota;","&Kappa;","&Lambda;","&Mu;","&Nu;","&Xi;","&Omicron;","&Pi;","&Rho;","&Sigma;","&Tau;","&Upsilon;","&Phi;","&Chi;","&Psi;","&Omega;","&alpha;","&beta;","&gamma;","&delta;","&epsilon;","&zeta;","&eta;","&theta;","&iota;","&kappa;","&lambda;","&mu;","&nu;","&xi;","&omicron;","&pi;","&rho;","&sigmaf;","&sigma;","&tau;","&upsilon;","&phi;","&chi;","&psi;","&omega;","&thetasym;","&upsih;","&piv;"];e["other"]=["&iexcl;","&cent;","&pound;","&curren;","&yen;","&brvbar;","&sect;","&uml;","&copy;","&ordf;","&laquo;","&not;","&reg;","&macr;","&deg;","&plusmn;","&sup2;","&sup3;","&acute;","&micro;","&para;","&middot;","&cedil;","&sup1;","&ordm;","&raquo;","&frac14;","&frac12;","&frac34;","&circ;","&tilde;","&ensp;","&emsp;","&thinsp;","&zwnj;","&zwj;","&lrm;","&rlm;","&ndash;","&mdash;","&lsquo;","&rsquo;","&sbquo;","&ldquo;","&rdquo;","&bdquo;","&dagger;","&Dagger;","&permil;","&lsaquo;","&rsaquo;","&euro;","&bull;","&hellip;","&prime;","&Prime;","&oline;","&frasl;","&weierp;","&image;","&real;","&trade;","&alefsym;","&larr;","&uarr;","&rarr;","&darr;","&harr;","&crarr;","&lArr;","&uArr;","&rArr;","&dArr;","&hArr;","&forall;","&part;","&exist;","&empty;","&nabla;","&isin;","&notin;","&ni;","&prod;","&sum;","&minus;","&lowast;","&radic;","&prop;","&infin;","&ang;","&and;","&or;","&cap;","&cup;","&int;","&there4;","&sim;","&cong;","&asymp;","&ne;","&equiv;","&le;","&ge;","&sub;","&sup;","&nsub;","&sube;","&supe;","&oplus;","&otimes;","&perp;","&sdot;","&lceil;","&rceil;","&lfloor;","&rfloor;","&lang;","&rang;","&loz;","&spades;","&clubs;","&hearts;","&diams;"];this.arEntities=[];for(i in this.arConfig["ar_entities"]){if(e[this.arConfig["ar_entities"][i]])this.arEntities=this.arEntities.concat(e[this.arConfig["ar_entities"][i]])}this.arEntities_h=BX.create("span",{html:this.arEntities.join(",")}).innerHTML.split(",");this.arConfig.undosize=this.arConfig.undosize||25;this.arConfig.width=this.arConfig.width||"750";this.pWnd.style.width=parseInt(this.arConfig.width)+(this.arConfig.width.indexOf("%")==-1?"px":"%");this.arConfig.height=this.arConfig.height||"500";this.pWnd.style.height=parseInt(this.arConfig.height)+(this.arConfig.height.indexOf("%")==-1?"px":"%");this.arToolbars=this.arConfig.arToolbars||["standart","style","formating","source","template"];if(this.arConfig["customToolbars"])this.customToolbars=this.arConfig["customToolbars"];this.pForm=BXFindParentByTagName(this.pWnd,"FORM");if(this.pForm)addAdvEvent(this.pForm,"submit",window["OnSubmit_"+this.name]);BX.addCustomEvent(window,"OnHtmlEditorRequestAuthFailure",BX.proxy(this.AuthFailureHandler,this));var o=this.pDocument.getElementById(this.name+"_pFrame");this.cEditor=BX(this.name+"_cEditor");window.IEplusDoctype=lightMode&&BX.browser.IsDoctype()&&BX.browser.IsIE();this.pFrame=o;if(BX.browser.IsIE()){setTimeout(function(){t.pFrame.style.position="absolute";setTimeout(function(){t.pFrame.style.position="static"},10)},800)}this.pEditorFrame=this.cEditor.appendChild(BX.create("IFRAME",{props:{id:"ed_"+this.name,className:"bx-editor-iframe",src:"javascript:void(0)",frameborder:0}}));if(this.pEditorFrame.contentDocument&&!BX.browser.IsIE())this.pEditorDocument=this.pEditorFrame.contentDocument;else this.pEditorDocument=this.pEditorFrame.contentWindow.document;this.pEditorWindow=this.pEditorFrame.contentWindow;this.pEditorDocument.className="pEditorDocument";this.pEditorDocument.pMainObj=this;this.pTopToolbarset=BX(this.name+"_toolBarSet0");if(!lightMode){this.arToolbarSet[0]=new BXToolbarSet(this.pTopToolbarset,this,false);this.arToolbarSet[1]=new BXToolbarSet(BX(this.name+"_toolBarSet1"),this,true)}this.arTaskbarSet[2]=new BXTaskbarSet(BX(this.name+"_taskBarSet2"),this,2);this.arTaskbarSet[3]=new BXTaskbarSet(BX(this.name+"_taskBarSet3"),this,3);this.pTaskTabs=BX(this.name+"_taskBarTabs");var r=BX.create("TEXTAREA",{props:{className:"bxeditor-textarea"},style:{height:"100%"}});if(BX.browser.IsIE()){this.pSourceDiv=this.cEditor.appendChild(this.CreateElement("DIV",{},{display:"none",height:"100%",width:"100%",overflowX:"hidden",overflowY:"auto",overflow:"auto"}));this.pSourceFrame=this.pSourceDiv.appendChild(r)}else{this.pSourceFrame=this.cEditor.appendChild(r)}this.pSourceFrame.onkeydown=function(t){var e=9;var i="  ";if(window.event){if(event.keyCode==e){this.selection=document.selection.createRange();this.selection.text=i;event.returnValue=false;return false}}else{if(t.keyCode==e){var o=this.selectionStart,r=this.selectionEnd,s=this.scrollTop,n=this.scrollLeft;this.value=this.value.substring(0,o)+i+this.value.substring(r);this.focus();this.setSelectionRange(o+(o!=r?0:1),o+i.length);this.scrollTop=s;this.scrollLeft=n;return false}}};this.pSourceFrame.onkeyup=function(){BX.onCustomEvent(t,"onChange")};pBXEventDispatcher.__Add(this);if(this.bDotNet&&this.pASPXParser&&this.pASPXParser.OnLoadSystem)this.pASPXParser.OnLoadSystem();BXHTMLEditor.prototype.OnDragDrop=function(t){if(this.sEditorMode=="code"||this.sEditorMode=="split"&&this.sEditorSplitMode=="code")return;if(this.nLastDragNDropElement&&this.nLastDragNDropElement.length>0){var e=this;setTimeout(function(){var i=e.pEditorDocument.getElementById(e.nLastDragNDropElement);if(!i)i=BX(e.nLastDragNDropElement);if(e.pEditorWindow.getSelection)e.pEditorWindow.getSelection().selectAllChildren(i);if(e.nLastDragNDropElementFire!==false)e.nLastDragNDropElementFire(i);e.OnClick(t)},10)}};BXHTMLEditor.prototype.__ShowTableBorder=function(t,e){var i=["border","borderBottom","borderBottomColor","borderBottomStyle","borderBottomWidth","borderCollapse","borderColor","borderLeft","borderLeftColor","borderLeftStyle","borderLeftWidth","borderRight","borderRightColor","borderRightStyle","borderRightWidth","borderStyle","borderTop","borderTopColor","borderTopStyle","borderTopWidth","borderWidth"];if(!t.border||t.border=="0"){try{if(e){t.setAttribute("__bxborderCollapse",t.style.borderCollapse);t.style.borderCollapse="collapse"}else{t.style.borderCollapse=t.getAttribute("__bxborderCollapse");t.removeAttribute("__bxborderCollapse")}}catch(t){}var o,r=t.getElementsByTagName("TD");for(var s=0;s<r.length;s++){o=r[s];if(e){if(!o.getAttribute("__bxborder")){o.setAttribute("__bxborder",BXSerializeAttr(o.style,i));o.style.border="1px #ACACAC dashed"}}else{if(o.getAttribute("__bxborder")){o.style.borderWidth="";o.style.borderColor="";o.style.borderStyle="";BXUnSerializeAttr(o.getAttribute("__bxborder"),o.style,i);o.removeAttribute("__bxborder")}}}}};BXHTMLEditor.prototype.Show=function(t){this.bShowed=t;if(t&&this.pWnd.style.display=="none")this.pWnd.style.display="block";else if(!t&&this.pWnd.style.display!="none")this.pWnd.style.display="none"};BXHTMLEditor.prototype.ShowTableBorder=function(t){if(this.bTableBorder==t)return false;this.bTableBorder=t;var e=this.pEditorDocument.getElementsByTagName("TABLE");for(var i=0;i<e.length;i++)this.__ShowTableBorder(e[i],t);return true};BXHTMLEditor.prototype.OnClick=function(t){if(!t)t=this.pEditorWindow.event;if(!t)t=window.event;if(t){var e=t.target||t.srcElement;if(e&&e.nodeType==1&&e.tagName&&e.tagName.toLowerCase()=="img")this.SelectElement(e)}if(this.__bMouseDownComp)return;if(this.pOnChangeSelectionTimer)clearTimeout(this.pOnChangeSelectionTimer);BX.onCustomEvent(this,"onChange");this.bFirstClick=true;var i=this;this.pOnChangeSelectionTimer=setTimeout(function(){i.OnEvent("OnSelectionChange")},200)};BXHTMLEditor.prototype.OnDblClick=function(e){var i,o=false;if(!e)e=this.pEditorWindow.event;if(e.target)i=e.target;else if(e.srcElement)i=e.srcElement;if(i.nodeType==3)i=i.parentNode;if(i&&i.nodeName)o=this.GetBxTag(i);if(o){if(o.tag=="img")this.OpenEditorDialog("image",null,500,{pElement:i});else if(o.tag=="a")this.OpenEditorDialog("editlink",null,520);if(o.tag=="anchor")this.OpenEditorDialog("anchor",null,400);if(o.tag=="flash")this.OpenEditorDialog("flash",null,500,{bUseTabControl:true,pMainObj:this})}t.OnEvent("OnDblClick",[e])};BXHTMLEditor.prototype.OnMouseUp=function(t){this.bFirstClick=true;if(this.pOnChangeSelectionTimer)clearTimeout(this.pOnChangeSelectionTimer);var e=this;this.pOnChangeSelectionTimer=setTimeout(function(){e.OnEvent("OnSelectionChange")},100)};this.pSourceFrame.onblur=function(e){t.pEditorFrame.onfocus(e)};this.pSourceFrame.onfocus=function(e){if(t.bEditSource)return;t.bEditSource=true;if(t.sEditorMode=="split"){t.SaveContent();t.OnEvent("ClearResourcesBeforeChangeView");t.SetCodeEditorContent(t.GetContent());t.sEditorSplitMode="code";t.OnEvent("OnChangeView",[this.sEditorMode,this.sEditorSplitMode])}};this.pEditorFrame.onfocus=function(e){if(!t.bEditSource)return;t.bEditSource=false;if(t.sEditorMode=="split"){t.SetEditorContent(t.GetCodeEditorContent());t.sEditorSplitMode="html";t.OnEvent("OnChangeView",[this.sEditorMode,this.sEditorSplitMode])}};this.value=this.pValue.value;BXStyleParser.Create();this.oStyles=new BXStyles(this);if(this.arConfig["TEMPLATE"])this.SetTemplate(this.arConfig["TEMPLATE"]["ID"],this.arConfig["TEMPLATE"],true);var s=window["ar_"+this.name+"_toolbars"];var n;if(!SETTINGS[this.name].arToolbarSettings)SETTINGS[this.name].arToolbarSettings=arToolbarSettings_default;var a=SETTINGS[this.name].arToolbarSettings;if(lightMode){var l=new BXGlobalToolbar(this),d=[],h;if(this.arConfig.toolbarConfig){var p={},u;for(var c=0,f=this.arConfig.toolbarConfig.length;c<f;c++){h=this.arConfig.toolbarConfig[c];if(h.indexOf("-")===-1&&h==parseInt(h)&&arGlobalToolbar[h]){d.push(arGlobalToolbar[h])}u=h.replace("-","");if(arGlobalToolbar[u]){p[arGlobalToolbar[u][1].id]=true}}for(c=0;c<arGlobalToolbar.length;c++){if(!p[arGlobalToolbar[c][1].id]){d.push(arGlobalToolbar[c])}}}else{d=arGlobalToolbar}l.LineBegin(true);for(var m=0,E=d.length;m<E;m++){var g=d[m];if(!g||g[1]&&g[1].hideCondition&&g[1].hideCondition(this))continue;if(typeof g=="object"){l.AddButton(this.CreateCustomElement(g[0],g[1]))}else if(g=="new_line"){l.LineEnd();l.LineBegin()}else if(g=="separator"){l.AddButton(this.CreateCustomElement("BXButtonSeparator"))}}l.LineEnd()}else{for(var b in arToolbars){if(s!==false&&!s[b]){delete arToolbars[b];continue}if(!a[b]){SETTINGS[this.name].arToolbarSettings[b]=arToolbarSettings_default[b];n=arToolbarSettings_default[b]}else{n=a[b]}if(BXSearchInd(this.arToolbars,b)<0&&this.customToolbars!==true)continue;var d=[],h;if(this.arConfig.toolbarConfig&&this.arConfig.toolbarConfig[b]){for(var c=0,f=this.arConfig.toolbarConfig[b].length;c<f;c++){h=this.arConfig.toolbarConfig[b][c];if(h.indexOf("-")===-1&&h==parseInt(h)&&arToolbars[b][1][h])d.push(arToolbars[b][1][h])}}else{d=arToolbars[b][1]}var g,m,E=d.length;if(!E){delete arToolbars[b];continue}var C=new BXToolbar(this,arToolbars[b][0],b);for(m=0;m<E;m++){g=d[m];if(!g||g[1]&&g[1].hideCondition&&g[1].hideCondition(this))continue;if(g=="separator"){C.AddButton(this.CreateCustomElement("BXButtonSeparator"))}else if(!g[1].id||!C.buttons[g[1].id]){C.AddButton(this.CreateCustomElement(g[0],g[1]));C.buttons[g[1].id]=true}}if(n.docked&&n.position)arDefaultTBPositions[b]=n.position;if(arDefaultTBPositions[b])this.arToolbarSet[arDefaultTBPositions[b][0]].AddToolbar(C,arDefaultTBPositions[b][1],arDefaultTBPositions[b][2]);else this.arToolbarSet[0].AddToolbar(C,100,0);if(!n.docked&&n.position)C.SetPosition(n.position.x,n.position.y);if(!n.show){C.Close();continue}C=null}n=null}setTimeout(function(){BXCreateTaskbars(t,true)},50);this.SetView("html");if(this.arConfig["fullscreen"]){this.pDocument.body.style.display="block";this.SetFullscreen(true)}this.start_func(this);o.style.display="";setTimeout(function(){BX.closeWait();t.bLoadFinish=true;t.SetFocus();try{jsUtils.onCustomEvent("EditorLoadFinish_"+t.name)}catch(t){}},10);this.ShowTableBorder(true);oBXContextMenu=this.CreateCustomElement("BXContextMenu");oBXContextMenu.Create();this.oBXVM=new BXVisualMinimize;jsUtils.addCustomEvent("OnToggleTabs",this.ClearPosCache,[],this);ar_BXTaskbarS=[];BXPopupWindow.bCreated=false;if(BX.WindowManager){var T=BX.WindowManager.Get();if(T){BX.addCustomEvent(T,"onWindowDragFinished",function(){CACHE_DISPATCHER["pEditorFrame_"+t.name]=null;CACHE_DISPATCHER["pEditorFrame"]=null})}}var S=t.pValue.form;if(S){if(S&&S.BXAUTOSAVE){try{BX.addCustomEvent(t,"onChange",function(){S.BXAUTOSAVE.Init()});BX.addCustomEvent(S,"onAutoSave",function(e,i){if(t.bShowed){t.SaveContent();i[t.name]=t.GetContent()}});BX.addCustomEvent(S,"onAutoSaveRestore",function(e,i){if(t.bShowed){t.SetContent(i[t.name]);t.LoadContent()}})}catch(t){}}}};BXHTMLEditor.prototype.SetContent=function(t){this.OnEvent("SetContentBefore",[t]);this.pValue.value=this.value=t;this.OnEvent("SetContentAfter",[t])};BXHTMLEditor.prototype.GetContent=function(){this.OnEvent("GetContent");return this.value.toString()};BXHTMLEditor.prototype.LoadContent=function(){this.OnEvent("LoadContentBefore");var t=this.GetContent();if(this.sFirstContent==null)this.sFirstContent=t;switch(this.sEditorMode){case"code":this.SetCodeEditorContent(t);break;case"split":this.SetCodeEditorContent(t);this.SetEditorContent(t);break;case"html":this.SetEditorContent(t)}this.OnEvent("LoadContentAfter")};BXHTMLEditor.prototype.SaveContent=function(){this.OnEvent("SaveContentBefore");switch(this.sEditorMode){case"code":this.SetContent(this.GetCodeEditorContent());break;case"split":if(this.sEditorSplitMode=="code")this.SetContent(this.GetCodeEditorContent());else this.SetContent(this.GetEditorContent(true,true));break;case"html":this.SetContent(this.GetEditorContent(true,true))}this.OnEvent("SaveContentAfter")};BXHTMLEditor.prototype.SetEditorContent=function(t){var e=this;t=this.pParser.SystemParse(t);if(this.pEditorDocument.designMode){try{this.pEditorDocument.designMode="off"}catch(t){_alert("SetEditorContent: designMode='off'")}}this.OnEvent("SetEditorContentBefore",[t]);this.pEditorDocument.open();this.pEditorDocument.write("<html><head></head><body"+this.bodyParams+">"+t+"</body></html>");this.pEditorDocument.close();this.pEditorDocument.body.style.padding="5px";this.pEditorDocument.body.style.margin="0";this.pEditorDocument.body.style.borderWidth="0";this.pParser.DOMHandle();if(this.bTableBorder){this.bTableBorder=false;this.ShowTableBorder(true)}if(BX.browser.IsIE()){this.pEditorDocument.body.contentEditable=true;addAdvEvent(this.pEditorDocument,"focus",window["onClick_"+this.name])}else{this.pEditorWindow.__bxedname=this.name;this.pEditorWindow.addEventListener("focus",this.FFOnFocus,false)}this.oStyles.SetToDocument(this.pEditorDocument);this.pEditorDocument.className="pEditorDocument";this.pEditorDocument.pMainObj=this;pBXEventDispatcher.SetEvents(this.pEditorDocument);addAdvEvent(this.pEditorDocument,"contextmenu",window["onContextMenu_"+this.name]);addAdvEvent(this.pEditorDocument,"click",window["onClick_"+this.name]);addAdvEvent(this.pEditorDocument,"dblclick",window["onDblClick_"+this.name]);addAdvEvent(this.pEditorDocument,"mouseup",window["onMouseUp_"+this.name]);addAdvEvent(this.pEditorDocument,"dragdrop",window["onDragDrop_"+this.name]);addAdvEvent(this.pEditorDocument,"keydown",BX.proxy(function(t){return this.OnKeyPress(t,true)},this));addAdvEvent(this.pEditorDocument,"keyup",BX.proxy(function(t){e.OnClick(t);e.OnChange("keyup","")},this));if(BX.browser.IsIE())addAdvEvent(this.pEditorDocument.body,"paste",window["onPaste_"+this.name]);addAdvEvent(this.pEditorDocument,"keydown",window["onKeyDown_"+this.name]);pBXEventDispatcher.OnEditorEvent("OnSetEditorContent",this);this.OnEvent("SetEditorContentAfter")};BXHTMLEditor.prototype.GetEditorContent=function(){this.OnEvent("GetEditorContentBefore");var t=this.bTableBorder;if(t)this.ShowTableBorder(false);this.pParser.Parse();if(t)this.ShowTableBorder(true);var e=this.pParser.GetHTML(true);e=this.pParser.ClearFromHBF(e);e=this.pParser.SystemUnParse(e);if(this.fullEditMode)e=this.pParser.AppendHBF(e,true);this.OnEvent("GetEditorContentAfter",[e]);return e};BXHTMLEditor.prototype.SetCodeEditorContent=function(t){this.pSourceFrame.value=t};BXHTMLEditor.prototype.GetCodeEditorContent=function(){return this.PreparseHeaders(this.pSourceFrame.value)};BXHTMLEditor.prototype.PreparseHeaders=function(t){if(!this.fullEditMode)return t;return this.pParser.GetHBF(t,true)};BXHTMLEditor.prototype.SetView=function(t){if(this.sEditorMode==t)return;var e=this;this.SaveContent();switch(t){case"code":this.pSourceFrame.style.height="99%";this.pEditorFrame.style.display="none";this._DisplaySourceFrame();if(BX.browser.IsIE()){this.pSourceFrame.rows="50";this.pSourceDiv.style.height="99%";this.pSourceDiv.style.display="block"}this.pSourceFrame.style.borderTop="0px solid #808080";var i=this.arTaskbarSet[2],o=this.arTaskbarSet[3];this.oTaskbarsInHtmlMode={rightTaskbar:i.bShowing,bottomTaskbar:o.bShowing};if(i.bShowing)i.Display(false);if(o.bShowing)o.Display(false);this.oBXTaskTabs.Refresh();this.SetCodeEditorContent(this.GetContent());setTimeout(function(){e.pSourceFrame.focus()},200);break;case"split":this.pEditorFrame.style.height="50%";if(BX.browser.IsIE()){this.pSourceFrame.style.height="97%";this.pSourceFrame.rows="40";this.pSourceDiv.style.overflow="hidden";this.pSourceDiv.style.height="49%";this.pSourceDiv.style.display="block"}else{this.pSourceFrame.style.height="49%"}this.pSourceFrame.style.borderTop="2px solid #808080";this._DisplaySourceFrame();this.pEditorFrame.style.display="block";if(this.sEditorMode=="code")this.SetEditorContent(this.GetContent());else if(this.sEditorMode=="html")this.SetCodeEditorContent(this.GetContent());break;default:this.pEditorFrame.style.height="100%";this.pSourceFrame.style.display="none";this.pEditorFrame.style.display="block";if(IEplusDoctype)this.pSourceDiv.style.display="none";if(this.oTaskbarsInHtmlMode){if(this.oTaskbarsInHtmlMode.rightTaskbar)this.arTaskbarSet[2].Display(true);if(this.oTaskbarsInHtmlMode.bottomTaskbar)this.arTaskbarSet[3].Display(true);this.oBXTaskTabs.Refresh();this.oTaskbarsInHtmlMode=null}this.SetEditorContent(this.GetContent());t="html"}this.arTaskbarSet[3].Resize();this.sEditorMode=t;this.SetCursorFF();this.OnEvent("OnChangeView",[this.sEditorMode,this.sEditorSplitMode])};BXHTMLEditor.prototype.SetCursorFF=function(){if(this.sEditorMode!="code"&&!BX.browser.IsIE()){var t=this;try{this.pEditorFrame.blur();this.pEditorFrame.focus();setTimeout(function(){t.pEditorFrame.blur();t.pEditorFrame.focus()},600);setTimeout(function(){t.pEditorFrame.blur();t.pEditorFrame.focus()},1e3)}catch(t){}}};BXHTMLEditor.prototype._DisplaySourceFrame=function(t){if(t&&this.sEditorMode!="code"&&this.sEditorMode!="split")return;if(BX.browser.IsIE()){this.pSourceFrame.style.display="none";var e=this;setTimeout(function(){e.pSourceFrame.style.display="block"},100)}else{this.pSourceFrame.style.display="block"}};BXHTMLEditor.prototype.PasteAsText=function(t){t=bxhtmlspecialchars(t);t=t.replace(/\r/g,"");t=t.replace(/\n/g,"<br/>");this.insertHTML(t)};BXHTMLEditor.prototype.CleanWordText=function(t,e){t=t.replace(/<(P|B|U|I|STRIKE)>&nbsp;<\/\1>/g," ");t=t.replace(/<o:p>([\s\S]*?)<\/o:p>/gi,"$1");t=t.replace(/<span[^>]*display:\s*?none[^>]*>([\s\S]*?)<\/span>/gi,"");t=t.replace(/<!--\[[\s\S]*?\]-->/gi,"");t=t.replace(/<!\[[\s\S]*?\]>/gi,"");t=t.replace(/<\\?\?xml[^>]*>/gi,"");t=t.replace(/<o:p>\s*<\/o:p>/gi,"");t=t.replace(/<\/?[a-z1-9]+:[^>]*>/gi,"");t=t.replace(/<([a-z1-9]+[^>]*) class=([^ |>]*)(.*?>)/gi,"<$1$3");t=t.replace(/<([a-z1-9]+[^>]*) [a-z]+:[a-z]+=([^ |>]*)(.*?>)/gi,"<$1$3");if(e.spaces){t=t.replace(/&nbsp;/gi," ");t=t.replace(/\s+?/gi," ")}t=t.replace(/\s*mso-[^:]+:[^;"]+;?/gi,"");t=t.replace(/\s*margin: 0cm 0cm 0pt\s*;/gi,"");t=t.replace(/\s*margin: 0cm 0cm 0pt\s*"/gi,'"');if(e.indents){t=t.replace(/\s*TEXT-INDENT: 0cm\s*;/gi,"");t=t.replace(/\s*TEXT-INDENT: 0cm\s*"/gi,'"')}t=t.replace(/\s*TEXT-ALIGN: [^\s;]+;?"/gi,'"');t=t.replace(/\s*PAGE-BREAK-BEFORE: [^\s;]+;?"/gi,'"');t=t.replace(/\s*FONT-VARIANT: [^\s;]+;?"/gi,'"');t=t.replace(/\s*tab-stops:[^;"]*;?/gi,"");t=t.replace(/\s*tab-stops:[^"]*/gi,"");if(e.fonts){t=t.replace(/<FONT[^>]*>([\s\S]*?)<\/FONT>/gi,"$1");t=t.replace(/\s*face="[^"]*"/gi,"");t=t.replace(/\s*face=[^ >]*/gi,"");t=t.replace(/\s*FONT-FAMILY:[^;"]*;?/gi,"")}t=t.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi,"<$1$3");if(e.styles)t=t.replace(/<(\w[^>]*) style="([^\"]*)"([^>]*)/gi,"<$1$3");t=t.replace(/\s*style="\s*"/gi,"");t=t.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi,"<$1$3");var i=0;while(t.toLowerCase().indexOf("<span")!=-1&&t.toLowerCase().indexOf("</span>")!=-1&&i++<20)t=t.replace(/<span[^>]*?>([\s\S]*?)<\/span>/gi,"$1");var o,r,s,n=["b","strong","i","u","font","span","strike"];while(true){o=t;for(r in n){s=n[r];t=t.replace(new RegExp("<"+s+"[^>]*?>(\\s*?)<\\/"+s+">","gi"),"$1");t=t.replace(new RegExp("<\\/"+s+"[^>]*?>(\\s*?)<"+s+">","gi"),"$1")}if(o==t)break}t=t.replace(/<(?:[^\s>]+)[^>]*>([\s\n\t\r]*)<\/\1>/g,"$1");t=t.replace(/<(?:[^\s>]+)[^>]*>(\s*)<\/\1>/g,"$1");t=t.replace(/<(?:[^\s>]+)[^>]*>(\s*)<\/\1>/g,"$1");t=t.replace(/<xml[^>]*?(?:>\s*?<\/xml)?(?:\/?)?>/gi,"");t=t.replace(/<meta[^>]*?(?:>\s*?<\/meta)?(?:\/?)?>/gi,"");t=t.replace(/<link[^>]*?(?:>\s*?<\/link)?(?:\/?)?>/gi,"");t=t.replace(/<style[\s\S]*?<\/style>/gi,"");if(e.tableAtr)t=t.replace(/<table([\s\S]*?)>/gi,"<table>");if(e.trtdAtr){t=t.replace(/<tr([\s\S]*?)>/gi,"<tr>");t=t.replace(/(<td[\s\S]*?)width=("|')[\s\S]*?\2([\s\S]*?>)/gi,"$1$3");t=t.replace(/(<td[\s\S]*?)height=("|')[\s\S]*?\2([\s\S]*?>)/gi,"$1$3");t=t.replace(/(<td[\s\S]*?)style=("|')[\s\S]*?\2([\s\S]*?>)/gi,"$1$3");t=t.replace(/(<td[\s\S]*?)valign=("|')[\s\S]*?\2([\s\S]*?>)/gi,"$1$3");t=t.replace(/(<td[\s\S]*?)nowrap=("|')[\s\S]*?\2([\s\S]*?>)/gi,"$1$3");t=t.replace(/(<td[\s\S]*?)nowrap([\s\S]*?>)/gi,"$1$3");t=t.replace(/(<col[\s\S]*?)width=("|')[\s\S]*?\2([\s\S]*?>)/gi,"$1$3");t=t.replace(/(<col[\s\S]*?)style=("|')[\s\S]*?\2([\s\S]*?>)/gi,"$1$3")}if(BX.browser.IsOpera())t=t.replace(/REF\s+?_Ref\d+?[\s\S]*?MERGEFORMAT\s([\s\S]*?)\s[\s\S]*?<\/xml>/gi," $1 ");return t};BXHTMLEditor.prototype.PasteWord=function(t,e){this.insertHTML(this.CleanWordText(t,e))};BXHTMLEditor.prototype.LoadTemplateParams=function(t){var e=this;return BX.ajax.post(editor_action_path+"&action=sitetemplateparams&lang="+BXLang+"&site="+BXSite+"&templateID="+t,{},function(){setTimeout(function(){e.SetTemplate(window.bx_template_params["ID"],window.bx_template_params,false)},100)})};BXHTMLEditor.prototype.SetTemplate=function(t,e,i){if(this.templateID&&this.templateID==t||e===false)return;if(!e)return this.LoadTemplateParams(t);this.templateID=e["ID"];if(this.pTemplateListbox)this.pTemplateListbox.SelectByVal(this.templateID);this.arTemplateParams=e;if(i){this.SaveContent();if(this.bDotNet)this.SetTemplate_ex();this.LoadContent()}if(to_template_path&&this.arTemplateParams.ID)this.oStyles.Parse(this.arTemplateParams["STYLES"],to_template_path+this.arTemplateParams.ID);var o=this.arTemplateParams["STYLES_TITLE"];if(o){for(var r in o)if(r&&r!=r.toLowerCase()&&!o[r.toLowerCase()])o[r.toLowerCase()]=o[r]}this.oStyles.SetToDocument(this.pEditorDocument);var s=this;if(this.pParser.strStyleNodes)setTimeout(function(){s.pParser.AppendCSS(s.pParser.strStyleNodes)},300);this.OnEvent("OnTemplateChanged")};BXHTMLEditor.prototype.SetFocus=function(){if(!this.bEditSource)BX.focus(this.pEditorWindow.focus?this.pEditorWindow:this.pEditorDocument.body)};BXHTMLEditor.prototype.insertHTML=function(t){this.SetFocus();try{if(BX.browser.IsIE()){var e=this.pEditorDocument.selection.createRange();e.pasteHTML(t);e.collapse(false);e.select()}else if(BX.browser.IsIE11()){this.PasteHtmlAtCaret(t)}else{this.pEditorWindow.document.execCommand("insertHTML",false,t)}}catch(t){}this.OnChange("insertHTML","")};BXHTMLEditor.prototype.PasteHtmlAtCaret=function(t,e){var i=this.pEditorWindow,o=this.pEditorDocument,r,s;if(i.getSelection){r=i.getSelection();if(r.getRangeAt&&r.rangeCount){s=r.getRangeAt(0);s.deleteContents();var n=o.createElement("div");n.innerHTML=t;var a=o.createDocumentFragment(),l,d;while(l=n.firstChild)d=a.appendChild(l);var h=a.firstChild;s.insertNode(a);if(d){s=s.cloneRange();s.setStartAfter(d);if(e)s.setStartBefore(h);else s.collapse(true);r.removeAllRanges();r.addRange(s)}}}else if((r=o.selection)&&r.type!="Control"){var p=r.createRange();p.collapse(true);r.createRange().pasteHTML(t);if(e){s=r.createRange();s.setEndPoint("StartToStart",p);s.select()}}};BXHTMLEditor.prototype.OnContextMenu=function(t,e,i,o){var r=this,s;r.OnEvent("OnSelectionChange");if(r.pEditorWindow.event)t=r.pEditorWindow.event;if(!t)t=window.event;if(!e)e=t.target||t.srcElement;if(t.pageX||t.pageY){t.realX=t.pageX;t.realY=t.pageY;if(!i){t.realX-=r.pEditorDocument.body.scrollLeft;t.realY-=r.pEditorDocument.body.scrollTop}}else if(t.clientX||t.clientY){t.realX=t.clientX;t.realY=t.clientY;if(i){t.realX+=document.body.scrollLeft;t.realY+=document.body.scrollTop}}if(!i){if(!(s=CACHE_DISPATCHER["pEditorFrame_"+this.name]))CACHE_DISPATCHER["pEditorFrame_"+this.name]=s=BX.pos(r.pEditorFrame);t.realX+=s["left"];t.realY+=s["top"]}oBXContextMenu.Show(2500,0,{left:t.realX,top:t.realY},e,o,this);return BX.PreventDefault(t)};BXHTMLEditor.prototype.executeCommand=function(t,e){this.SetFocus();try{var i=this.pEditorWindow.document.execCommand(t,false,e)}catch(t){}this.SetFocus();this.OnEvent("OnSelectionChange");this.OnChange("executeCommand",t);return i};BXHTMLEditor.prototype.queryCommand=function(t){var e="";try{if(!this.pEditorDocument.queryCommandEnabled(t))return null}catch(t){return null}try{return this.pEditorDocument.queryCommandValue(t)}catch(t){}return null};BXHTMLEditor.prototype.queryCommandState=function(t){var e="";try{if(!this.pEditorDocument.queryCommandEnabled(t))return"DISABLED"}catch(t){return"DISABLED"}try{return this.pEditorDocument.queryCommandState(t)?"CHECKED":"ENABLED"}catch(t){return"ENABLED"}return"DISABLED"};BXHTMLEditor.prototype.updateBody=function(){this.extractBodyParams(this._body)};BXHTMLEditor.prototype.extractBodyParams=function(t){var e=t.replace(/<body(.*?)>/i,"$1");var i=e.match(/\w+\s*=".*?"/gi);var o=[];var r;for(var s in i){if(parseInt(s).toString()=="NaN")continue;var i=e.match(/(\w+)\s*=".*?"/gi);r=i[s].replace(/(\w+)\s*="(.*?)"/gi,"$2");o[RegExp.$1]=r}};BXHTMLEditor.prototype.FFOnFocus=function(t){try{var e=GLOBAL_pMainObj[this.__bxedname];if(e.pEditorDocument.designMode=="on")return;e.pEditorDocument.designMode="on";e.pEditorDocument.execCommand("styleWithCSS",false,false);setTimeout(function(){try{e.pEditorDocument.execCommand("styleWithCSS",false,false)}catch(t){}},1e3);this.document.execCommand("insertBrOnReturn",false,false)}catch(t){}};BXHTMLEditor.prototype.onSubmit=function(t){if(!this.isSubmited){this.isSubmited=true;BX.cleanNode(this.oPropertiesTaskbar.pCellProps);if(!this.sEditorMode)this.sEditorMode="html";this.OnEvent("OnSubmit");if(this.bShowed)this.SaveContent();this.Show(false)}};BXHTMLEditor.prototype.OnKeyDown=function(t){if(!t)t=this.pEditorWindow.event;var e=t.which||t.keyCode;if(!BX.browser.IsIE()&&!BX.browser.IsOpera()){if(t.ctrlKey&&!t.shiftKey&&!t.altKey){switch(e){case 66:case 98:this.executeCommand("Bold");return BX.PreventDefault(t);case 105:case 73:this.executeCommand("Italic");return BX.PreventDefault(t);case 117:case 85:this.executeCommand("Underline");return BX.PreventDefault(t)}}}if(e==16){var i=this;this._bShiftPressed=true;setTimeout(function(){i._bShiftPressed=false},200)}else if(e==9){if(this._bShiftPressed||t.shiftKey){this.executeCommand("Outdent");return BX.PreventDefault(t)}else{this.executeCommand("Indent");return BX.PreventDefault(t)}}if(t.ctrlKey&&e==86||(this._bShiftPressed||t.shiftKey)&&e==45)this.OnCtrlV()};BXHTMLEditor.prototype.OnCtrlV=function(){var t={},e=this;setTimeout(function(){CheckChilds(e.pEditorDocument.body,{func:function(i){if(i.nodeType!=1)return;var o=i.id;if(!o||o.substr(0,5)!="bxid_")return;if(t[o]===true){var r=e.GetBxTag(i);if(r.tag){r.id=null;delete r.id;i.id="";i.removeAttribute("id");var s=e.SetBxTag(i,copyObj(r));if(r.tag=="component2"&&e.pComponent2Taskbar){e.pComponent2Taskbar.SetParams({id:s,params:copyObj(e.pComponent2Taskbar.GetParams({id:o}))})}t[s]=true}}else{t[o]=true}},obj:e});t=null},500)};BXHTMLEditor.prototype.OnPaste=function(t){var e=this.GetClipboardHTML();var i=true;if(i){var o=/<\w[^>]*(( class="?MsoNormal"?)|(="mso-))/gi;if(o.test(e)){if(confirm(BX_MESS.MaybeTextFromWord)){this.bNotFocus=true;this.pMainObj.OpenEditorDialog("pasteword",false,450);t.returnValue=false;t.cancelBubble=true}else return}}};BXHTMLEditor.prototype.GetClipboardHTML=function(){var t=document.createElement("DIV");t.style.visibility="hidden";t.style.overflow="hidden";t.style.position="absolute";t.style.width=1;t.style.height=1;document.body.appendChild(t);t.innerHTML="";var e=document.body.createTextRange();e.moveToElementText(t);e.execCommand("Paste");var i=t.innerHTML;t.innerHTML="";return i};BXHTMLEditor.prototype.OnKeyPress=function(t,e){this.bFirstClick=true;if(!t)t=window.event;if(t.keyCode==27){if(this.oPublicDialog&&!this.CheckSubdialogs())return this.oPublicDialog.Close();if(window.oBXEditorDialog&&window.oBXEditorDialog.isOpen)return window.oBXEditorDialog.Close();if(window.oBXContextMenu&&oBXContextMenu.menu&&oBXContextMenu.menu.IsVisible())oBXContextMenu.menu.PopupHide()}if(!e&&t.keyCode==13){var i=t.target||t.srcElement;if(i&&i.nodeName.toUpperCase()=="TEXTAREA")return true;return BX.PreventDefault(t)}return true};BXHTMLEditor.prototype.RemoveElements=function(t,e,i,o){var r;r=t.children;if(r){for(var s=0;s<r.length;s++){var n=r[s];this.RemoveElements(n,e,i);if(n.tagName.toLowerCase()!=e.toLowerCase())continue;var a=true;for(var l in i){attrValue=i[l];switch(l.toLowerCase()){case"style":var d=attrValue.toLowerCase();var h=/([^:]+):[^;]+/g;var p;while((p=h.exec(d))!=null){var u=RegExp.$1;if(n.style.cssText.toLowerCase().indexOf(u.toLowerCase())==-1){a=false;break}}break;case"class":if(n.getAttribute("className",0)!=attrValue)a=false;break;default:if(n.getAttribute(attrNalue,0)!=attrValue)a=false}}if(a){n.insertAdjacentHTML("beforeBegin",n.innerHTML);n.parentElement.removeChild(n)}}}};BXHTMLEditor.prototype.WrapSelectionWith=function(t,e){this.SetFocus();var i,o;if(!t)t="SPAN";var r="FONT",s,n,a,l=[];try{this.pEditorDocument.execCommand("styleWithCSS",false,false)}catch(t){}this.executeCommand("FontName","bitrixtemp");try{this.pEditorDocument.execCommand("styleWithCSS",false,false)}catch(t){}a=this.pEditorDocument.getElementsByTagName(r);for(s=a.length-1;s>=0;s--){if(a[s].getAttribute("face")!="bitrixtemp")continue;n=BX.create(t,e,this.pEditorDocument);l.push(n);while(a[s].firstChild)n.appendChild(a[s].firstChild);a[s].parentNode.insertBefore(n,a[s]);a[s].parentNode.removeChild(a[s])}return l};BXHTMLEditor.prototype.RidOfNode=function(t,e){if(!t||t.nodeType!=1)return;var i,o=t.tagName.toLowerCase();if(o=="span"||o=="strike"||o=="font"){if(e!==true){for(i=t.attributes.length-1;i>=0;i--){if(BX.util.trim(t.getAttribute(t.attributes[i].nodeName.toLowerCase()))!="")return false}}var r=t.childNodes;while(r.length>0)t.parentNode.insertBefore(r[0],t);t.parentNode.removeChild(t);this.OnEvent("OnSelectionChange");return true}return false};BXHTMLEditor.prototype.GetToolbarSet=function(){return this.arToolbarSet};BXHTMLEditor.prototype.GetTaskbarSet=function(){return this.arTaskbarSet};BXHTMLEditor.prototype.SelectElement=function(t){if(this.pEditorWindow.getSelection){var e=this.pEditorWindow.getSelection();e.selectAllChildren(t);i=e.getRangeAt(0)}else{this.pEditorDocument.selection.empty();var i=this.pEditorDocument.selection.createRange();if(i.moveToElementText)i.moveToElementText(t);i.select()}return i};BXHTMLEditor.prototype.CollapseSelection=function(){if(this.pEditorWindow.getSelection){var t=this.pEditorWindow.getSelection();if(t.collapseToEnd)t.collapseToEnd()}else if(this.pEditorDocument&&this.pEditorDocument.selection&&this.pEditorDocument.selection.empty){this.pEditorDocument.selection.empty()}};BXHTMLEditor.prototype.GetSelectedNode=function(t){var e;if(this.pEditorDocument.selection&&!BX.browser.IsIE9()){e=this.pEditorDocument.selection;var i=e.createRange();if(e.type=="Control")return i.commonParentElement();if(i.parentElement()&&(i.text==i.parentElement().innerText||t))return i.parentElement().childNodes.length==1?i.parentElement().firstChild:i.parentElement();return i}else{e=this.pEditorWindow.getSelection();if(!e||e.rangeCount!=1)return false;var o,r;o=e.getRangeAt(0);r=o.startContainer;if(r.nodeType!=3){if(r.nodeType==1&&r.childNodes.length<=0)return r;else if(o.endOffset-o.startOffset==r.childNodes.length)return r;else if(o.endOffset-o.startOffset<2)return r.childNodes[o.startOffset];else return false}return r}};BXHTMLEditor.prototype.GetSelectionObjects=function(){var t;if(this.pEditorDocument.selection&&!BX.browser.IsIE9()){t=this.pEditorDocument.selection;var e=t.createRange();if(t.type=="Control")return e.commonParentElement();return e.parentElement()}else{t=this.pEditorWindow.getSelection();if(!t)return false;var i;var o,r;var s=[];for(var n=0;n<t.rangeCount;n++){i=t.getRangeAt(n);o=i.startContainer;if(o.nodeType!=3){if(o.nodeType==1&&o.childNodes.length<=0)s[s.length]=o;else s[s.length]=o.childNodes[i.startOffset]}else{r=i.commonAncestorContainer;while(r&&r.nodeType==3)r=r.parentNode;s[s.length]=r}}if(s.length>1)return s;return s[0]}};BXHTMLEditor.prototype.OptimizeHTML=function(t){var e=0,i=true,o=["b","em","font","h\\d","i","li","ol","small","span","strong","u","ul"],r=function(){a--;i=true;return" "},s,n,a,l;while(e++<20&&i){i=false;for(a=0,l=o.length;a<l;a++){n=o[a];s=new RegExp("<"+n+"[^>]*?>\\s*?</"+n+">","ig");t=t.replace(s,r);s=new RegExp("<"+n+"\\s+?[^>]*?/>","ig");t=t.replace(s,r);if(n!=="li"){s=new RegExp("<(("+n+"+?)(?:\\s+?[^>]*?)?)>([\\s\\S]+?)<\\/\\2>\\s*?<\\1>([\\s\\S]+?)<\\/\\2>","ig");t=t.replace(s,function(t,e,o,r,s){i=true;return"<"+e+">"+r+" "+s+"</"+o+">"})}}}return t};BXHTMLEditor.prototype.GetSelectionObject=function(){var t=this.GetSelectionObjects();if(t&&t.constructor==Array){var e=t[0];for(var i=1;i<t.length;i++)e=BXFindParentElement(e,t[i]);return e}return t};BXHTMLEditor.prototype.CreateEditorElement=function(t,e,i){return BXCreateElement(t,e,i,this.pEditorDocument)};BXHTMLEditor.prototype.CreateCustomElement=function(t,e){var i=new window[t];ar_CustomElementS.push(i);i.pMainObj=this;i.pDocument=this.pDocument;i.CreateElement=BXCreateElement;if(e){var o;for(o in e)if(o.toLowerCase()=="_oncreate")e[o].apply(i);else i[o]=e[o]}if(i._Create)i._Create();return i};BXHTMLEditor.prototype.AddEventHandler=function(t,e,i){if(!this.arEventHandlers[t])this.arEventHandlers[t]=[];this.arEventHandlers[t].push([e,i])};BXHTMLEditor.prototype.OnEvent=function(t,e){if(!this.arEventHandlers[t])return true;var i=true;for(var o=0;o<this.arEventHandlers[t].length;o++){if(this.arEventHandlers[t][o][1]){if(!e)e=[];if(!this.arEventHandlers[t][o][0].apply(this.arEventHandlers[t][o][1],e))i=false}else{if(!this.arEventHandlers[t][o][0](e))i=false}}return i};BXHTMLEditor.prototype.FullResize=function(){var t=BX.GetWindowInnerSize();window.__fswindow.style.width=parseInt(t.innerWidth)+"px";window.__fswindow.style.height=parseInt(t.innerHeight)+"px";this.OnEvent("OnFullResize",[])};BXHTMLEditor.prototype.ClearPosCache=function(){CACHE_DISPATCHER["BXTaskbarset_VPos_"+this.name]=null;CACHE_DISPATCHER["BXTasktab_VPos_"+this.name]=null;CACHE_DISPATCHER["pEditorFrame_"+this.name]=null;CACHE_DISPATCHER["pEditorFrame"]=null;CACHE_DISPATCHER["BXToolbarSet_pos_0"]=null;CACHE_DISPATCHER["BXToolbarSet_pos_1"]=null;CACHE_DISPATCHER["BXToolbarSet_pos_2"]=null;CACHE_DISPATCHER["BXToolbarSet_pos_3"]=null};BXHTMLEditor.prototype.SetFullscreen=function(t){this.ClearPosCache();var e=this;if(t){var i=BX.GetWindowInnerSize();BX.addClass(this.pWnd,"bxedmain-fullscreen");this.pDocument.body.style.overflow="hidden";this.__oldSize=[this.pWnd.style.width,this.pWnd.style.height];var o=parseInt(i.innerWidth);var r=parseInt(i.innerHeight);if(BX.browser.IsIE()&&!IEplusDoctype)o+=18;this.pWnd.style.width=o+"px";this.pWnd.style.height=r+"px";window.scrollTo(0,0);window.__fswindow=this.pWnd;window._bxonresize=window.onresize||null;window.onresize=function(){e.FullResize()}}else{BX.removeClass(this.pWnd,"bxedmain-fullscreen");this.pDocument.body.style.overflow="auto";if(!this.__oldSize)return;this.pWnd.style.width=this.__oldSize[0];this.pWnd.style.height=this.__oldSize[1];window.__fswindow=null;window.onresize=window._bxonresize||null;var s=this.arTaskbarSet[3].pWnd;if(parseInt(s.offsetHeight)>=245){s.style.height="245px";var n=this.arTaskbarSet[2].pParentWnd;var a=n.style.display;n.style.display="none";var e=this;setTimeout(function(){n.style.display=a;e.IEplusDoctypePatchSizes()},10)}this._DisplaySourceFrame(true)}this.arTaskbarSet[2]._SetTmpClass(true);this.arTaskbarSet[2].Resize();this.arTaskbarSet[3].Resize();this.bFullscreen=t;if(this.pDocument.getElementById("fullscreen"))this.pDocument.getElementById("fullscreen").value=t?"Y":"N";if(IEplusDoctype){this.IEplusDoctypePatchSizes();var s=this.arTaskbarSet[3].arTaskbars[0].pWnd;s.parentNode.appendChild(s)}this.SetCursorFF();this.OnEvent("OnFullscreen",[t])};BXHTMLEditor.prototype.ParseStyles=function(){this.arStyles=[]};BXHTMLEditor.prototype._FuncOnChange=function(t,e,i){return function(){t._OnChange(e,i)}};BXHTMLEditor.prototype.OnChange=function(t,e){if(this.bSkipChanges==true)return;if(!e)e="";if(this.sOnChangeLastType!=t||this.sOnChangeLastSubType!=e){this._OnChange(t,e);return}if(this.pOnChangeTimer)clearTimeout(this.pOnChangeTimer);this.pOnChangeTimer=setTimeout(this._FuncOnChange(this,t,e),1e3)};BXHTMLEditor.prototype.IsChanged=function(){if(!this.bFirstClick)return false;if(this.bNotSaved)return true;this.SaveContent();var t=this.sFirstContent.trim();var e=this.GetContent().trim();if(t.length==e.length&&t==e)return false;return true};BXHTMLEditor.prototype._OnChange=function(t,e){this.sOnChangeLastType=t;this.sOnChangeLastSubType=e;var i=this.pEditorDocument.body.innerHTML;if(this.sLastContent.length==i.length&&this.sLastContent==i)return;var o=this.sLastContent;this.sLastContent=i;if(BX.browser.IsIE()){if(t!="Undo"&&t!="Redo"){var r=this.arUndoBuffer.length;if(this.iUndoPos+1<r){this.arUndoBuffer.length=this.iUndoPos+1;r=this.iUndoPos+1}var s=false;if(this.pEditorDocument.selection){if(this.pEditorDocument.selection.type=="Text")s=this.pEditorDocument.selection.createRange().getBookmark()}this.arUndoBuffer.push({type:t,subtype:e,content:i,pos:s});var n=r-this.arConfig["undosize"];if(n>0){this.arUndoBuffer.reverse();this.arUndoBuffer.length=this.arUndoBuffer.length-n;this.arUndoBuffer.reverse()}this.iUndoPos=this.arUndoBuffer.length-1}this.bNotSaved=this.iUndoPos>0}else{if(this.iUndoPos<0)this.iUndoPos=0;else this.bNotSaved=true}this.OnEvent("OnChange")};BXHTMLEditor.prototype.SetXXdo=function(t){var e=this.arUndoBuffer[this.iUndoPos];this.pEditorDocument.body.innerHTML=e["content"];this._OnChange(t);this.sLastContent=this.pEditorDocument.body.innerHTML;if(e["pos"]){if(this.pEditorDocument.selection){var i=this.pEditorDocument.selection.createRange();i.moveToBookmark(e["pos"]);i.select()}}};BXHTMLEditor.prototype.UndoStatus=function(){return!(this.iUndoPos<1||this.arUndoBuffer.length<=0)};BXHTMLEditor.prototype.Undo=function(t){if(!this.UndoStatus())return;if(this.iUndoPos<t)this.iUndoPos=0;else this.iUndoPos=this.iUndoPos-t;this.SetXXdo("Undo")};BXHTMLEditor.prototype.RedoStatus=function(t){return!(this.iUndoPos+1>=this.arUndoBuffer.length||this.arUndoBuffer.length<=0)};BXHTMLEditor.prototype.Redo=function(t){if(!this.RedoStatus())return;if(this.iUndoPos+t>=this.arUndoBuffer.length)this.iUndoPos=this.arUndoBuffer.length-1;else this.iUndoPos=this.iUndoPos+t;this.SetXXdo("Redo")};BXHTMLEditor.prototype.Clean=function(t){return;this.pFrame=null;this.pWnd.pMainObj=null;this.pWnd=null;this.pForm=null;this.pComponent2Taskbar=null;this.pLoaderFrame=null;for(var e in this.arEventHandlers)this.arEventHandlers[e]=null;this.arEventHandlers=null;var i=this.arToolbarSet.length;for(var o=0;o<i;o++)this.arToolbarSet[o]=null;var i=this.arTaskbarSet.length;for(var o=0;o<i;o++)this.arTaskbarSet[o]=null;this.lineNumCont=null;this.pSourceFrame.onkeydown=null;this.pSourceFrame=null;this.pEditorWindow=null;this.pEditorFrame=null;this.pEditorDocument.pMainObj=null;this.pEditorDocument=null;this.pDocument=null;this.pParser=null};BXHTMLEditor.prototype.IEPatchSizesHandler=function(t){var e=this;setTimeout(function(){e.IEplusDoctypePatchSizes()},100)};BXHTMLEditor.prototype.IEplusDoctypePatchSizes=function(t){return;if(!IEplusDoctype)return;var e=this.arTaskbarSet[2];var i=this.arTaskbarSet[3];if(isNaN(t)){if(i.pWnd.style.display!="none")t=parseInt(i.pWnd.style.height);else t=0}else t=t-35;if(t==0)t=-33;var o=parseInt(this.bFullscreen?BX.GetWindowInnerSize().innerHeight:this.arConfig["height"]);var r=o-t-114;if(isNaN(r))return;this.pFrame.rows[1].style.height=r+"px";if(this.sEditorMode=="html"){this.pEditorFrame.style.height=r+"px"}else if(this.sEditorMode=="split"){this.pEditorFrame.style.height=Math.round(r/2)-3+"px";this.pSourceFrame.style.height=Math.round(r/2)-4+"px"}else if(this.sEditorMode=="code"){this.pSourceFrame.style.height=r-6+"px"}if(e.bShowing){var s,n,a;var l=e.arTaskbars.length;var d,h=25;if(l>1){d=25;e.pWnd.style.height=r-45+"px";e.pBottomColumn.style.height=d+"px"}else d=0;var p=r-h-d-6;for(var u=0;u<l;u++){s=e.arTaskbars[u].pWnd;s.rows[0].cells[0].style.height=h+"px";s.rows[1].cells[0].style.height=p+"px"}}var c,f};BXHTMLEditor.prototype.OnSpellCheck=function(){BX.closeWait();var t=false;if(this.pMainObj.arConfig["spellCheckFirstClient"]=="Y")t=SpellCheck_MS(this.pMainObj.pEditorDocument.body);var e=this.pMainObj.arConfig["usePspell"];var i="N";if(!t){if(e=="Y"||i=="Y"){this.bNotFocus=true;this.pMainObj.OpenEditorDialog("spellcheck",false,400,{BXLang:BXLang,usePspell:e,useCustomSpell:i},true)}else{alert(BX_MESS.SpellCheckNotInstalled)}}};BXHTMLEditor.prototype.SaveConfig=function(t,e){if(typeof e!="object")e={};e.edname=this.name;switch(t){case"tooltips":e.tooltips=this.showTooltips4Components?"Y":"N";break;case"visual_effects":e.visual_effects=this.visualEffects?"Y":"N";break;case"render_components":e.render_components=this.bRenderComponents?"Y":"N";break}return BX.ajax.post(settings_page_path+"&target="+t,e)};BXHTMLEditor.prototype.GetConfig=function(t){this.showTooltips4Components=SETTINGS[this.name].showTooltips4Components;this.visualEffects=SETTINGS[this.name].visualEffects;t.func.apply(t.obj)};BXHTMLEditor.prototype.RestoreConfig=function(){return BX.ajax.post(settings_page_path+"&target=unset&edname="+this.name,{},function(){alert(BX_MESS.RestoreSettingsMess)})};BXHTMLEditor.prototype.GetTaskbarConfig=function(t){if(SETTINGS[this.name].arTaskbarSettings[t])return SETTINGS[this.name].arTaskbarSettings[t];else if(arTaskbarSettings_default[t])return arTaskbarSettings_default[t];else return{show:true,set:2,active:false}};BXHTMLEditor.prototype.CheckTaskbar=function(t){return BXTaskbar&&typeof BXTaskbar=="object"&&BXTaskbar.pMainObj&&BXTaskbar.name&&!BXTaskbar.bDeleted};BXHTMLEditor.prototype.SetBxTag=function(t,e){var i;if(e.id||t&&t.id){i=e.id||t.id}if(!i){i="bxid_"+Math.round(Math.random()*1e6)}else{if(this.bxTags[i]){if(!e.tag)e.tag=this.bxTags[i].tag}}e.id=i;if(t)t.id=e.id;this.bxTags[e.id]=e;return e.id};BXHTMLEditor.prototype.GetBxTag=function(t){if(t){if(typeof t!="string"&&t.id)t=t.id;if(t&&t.length>0&&this.bxTags[t]&&this.bxTags[t].tag){this.bxTags[t].tag=this.bxTags[t].tag.toLowerCase();return this.bxTags[t]}}return{tag:false}};BXHTMLEditor.prototype.Add2BxTag=function(t,e){if(typeof t!="string")t=t.id;if(!t)return;var i=this.GetBxTag(t),o;for(o in e){if(typeof e[o]!="function"){i.params[o]=e[o]}}};BXHTMLEditor.prototype.CheckSubdialogs=function(){if(window.oBXEditorDialog&&window.oBXEditorDialog.isOpen||this.oTransOverlay.bShowed)return true;return false};BXHTMLEditor.prototype.AuthFailureHandler=function(t,e){if(t!=this.name||this._authShowed)return;var i=this;function o(){i._authShowed=false;if(i.__authFailureHandlerCallback)i.__authFailureHandlerCallback()}this._authShowed=true;var r=new BX.CAuthDialog({content_url:"/bitrix/admin/fileman_editor_dialog.php",auth_result:e,callback:BX.delegate(function(){if(o)o()},this)});r.Show();BX.addCustomEvent(r,"onWindowUnRegister",function(){i._authShowed=false;if(i.__authFailureHandlerCallbackClose)i.__authFailureHandlerCallbackClose()})};BXHTMLEditor.prototype.InsertHtmlEx=function(t,e){if(!e)e=50;var i="tmp_bxid_"+Math.round(Math.random()*1e6);this.insertHTML('<a id="'+i+'" href="#" _moz_editor_bogus_node="on">+</a>');var o=this.pEditorDocument;setTimeout(function(){var r=o.getElementById(i);if(r){r.innerHTML=t;setTimeout(function(){var t=o.getElementById(i);if(t){for(var e=t.childNodes.length-1;e>=0;e--)t.parentNode.insertBefore(t.childNodes[e],t);if(t.parentNode)t.parentNode.removeChild(t)}},e)}},e)};function BXContextMenuOnclick(t){removeEvent(this.pMainObj.pEditorDocument,"click",BXContextMenuOnclick);oBXContextMenu.menu.PopupHide()}function BXStyles(t){this.pMainObj=t;this.arStyles=[];this.sStyles="";BXStyles.prototype.Parse=function(t,e){this.templatePath=e||"";this.sStyles=t;this.arStyles=BXStyleParser.Parse(t)};BXStyles.prototype.GetStyles=function(t){if(this.arStyles[t.toUpperCase()])return this.arStyles[t.toUpperCase()];return[]};BXStyles.prototype.SetToDocument=function(t){var e=t.getElementsByTagName("HEAD");if(e.length!=1)return;var i=t.getElementsByTagName("STYLE");for(var o=0;o<i.length;o++)i[o].parentNode.removeChild(i[o]);var r=t.createElement("STYLE");e[0].appendChild(r);var s=this.sStyles;if(BX.browser.IsIE())t.styleSheets[0].cssText=s;else r.appendChild(t.createTextNode(s))}}BX.ready(BXEditorLoad);
//# sourceMappingURL=editor.map.js